
const gulp = require('gulp');
const rollup = require('rollup');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const sourcemaps = require('gulp-sourcemaps');
const rename = require("gulp-rename");
const pkg = require('./package.json');

gulp.task('build', function () {
    gulp.src(pkg.jscode.files)
        .pipe(babel({
            presets: ['env']
        }))
        .pipe(concat('editor.js'))
        .pipe(gulp.dest('debug/js'))
        .pipe(uglify())
        .pipe(rename({
            extname: '.min.js'
        }))
        .pipe(gulp.dest('release/js'));

    gulp.src(pkg.jscode.debug)
        .pipe(gulp.dest('debug/js'));

    gulp.src(pkg.jscode.release)
        .pipe(gulp.dest('release/js'));

    gulp.src(['app/www/webdebug/**/*'])
        .pipe(gulp.dest('debug'));

    gulp.src(['app/www/webrelease/**/*'])
        .pipe(gulp.dest('release'));
});